package com.fitzpatrickit.robotics.hexaped;

import lejos.robotics.subsumption.Behavior;

public class TurnLeftBehaviour implements Behavior {
	
	private volatile boolean suppressed = true;
	
	private final HexapedMoveController hexapedMoveController;
	
	public TurnLeftBehaviour(HexapedMoveController controller) {
		this.hexapedMoveController = controller;
	}

	@Override
	public boolean takeControl() {
		return true;
	}

	@Override
	public void action() {
		this.suppressed = false;
		
		this.hexapedMoveController.turnLeft();
		
		while (!this.suppressed) {
			Thread.yield();
		}
		
		this.hexapedMoveController.stop();
	}

	@Override
	public void suppress() {
		this.suppressed = true;
	}

}
